{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from urllib.robotparser import RobotFileParser\n",
    "\n",
    "rp=RobotFileParser('https://www.ctrip.com/robots.txt')\n",
    "\n",
    "print(rp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<html><body><div>\n",
      "    <ul>\n",
      "         <li class=\"item-0\"><a href=\"link1.html\">first item</a></li>\n",
      "         <li class=\"item-1\"><a href=\"link2.html\">second item</a></li>\n",
      "         <li class=\"item-inactive\"><a href=\"link3.html\">third item</a></li>\n",
      "         <li class=\"item-1\"><a href=\"link4.html\">fourth item</a></li>\n",
      "         <li class=\"item-0\"><a href=\"link5.html\">fifth item</a>\n",
      "     </li></ul>\n",
      " </div>\n",
      "</body></html>\n"
     ]
    }
   ],
   "source": [
    "from lxml import etree\n",
    "text = '''\n",
    "<div>\n",
    "    <ul>\n",
    "         <li class=\"item-0\"><a href=\"link1.html\">first item</a></li>\n",
    "         <li class=\"item-1\"><a href=\"link2.html\">second item</a></li>\n",
    "         <li class=\"item-inactive\"><a href=\"link3.html\">third item</a></li>\n",
    "         <li class=\"item-1\"><a href=\"link4.html\">fourth item</a></li>\n",
    "         <li class=\"item-0\"><a href=\"link5.html\">fifth item</a>\n",
    "     </ul>\n",
    " </div>\n",
    "'''\n",
    "html=etree.HTML(text)\n",
    "res=etree.tostring(html)\n",
    "print(res.decode('utf-8'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
